Skip to content

Comments

Cloud-native MEAN boilerplate#2

Closed
LouisLetcher wants to merge 2 commits intomainfrom
cursor/cloud-native-mean-boilerplate-7f8f
Closed

Cloud-native MEAN boilerplate#2
LouisLetcher wants to merge 2 commits intomainfrom
cursor/cloud-native-mean-boilerplate-7f8f

Conversation

@LouisLetcher
Copy link
Contributor

Add a comprehensive, cloud-native MEAN stack boilerplate adhering to modern best practices.


Open in Web Open in Cursor 

…ecks, and tests

- TypeScript strict mode with Zod env validation
- Modular architecture: health, auth, users modules
- Security middleware: Helmet, CORS, rate limiting
- Structured logging with Pino
- Centralized error handling with custom AppError classes
- JWT authentication with bcrypt password hashing
- RESTful API with standardized JSON responses
- Multi-stage Dockerfile for dev/prod
- Docker Compose with MongoDB, backend, frontend services
- Jest test suite (14 passing tests)
- ESLint + Prettier configuration
- Husky + lint-staged + commitlint for git hooks
- Angular 19 with standalone components, signals, and new control flow
- Lazy-loaded routes: home, auth (login/register), dashboard
- Auth service with signal-based state management
- HTTP interceptor for JWT token injection and 401 handling
- Auth/guest guards for route protection
- SCSS styling with modern UI design
- Multi-stage Dockerfile (dev with ng serve, prod with Nginx)
- Nginx config with gzip, caching, SPA fallback, API proxy
- GitHub Actions CI: lint, type-check, test, build, Docker verify
- Comprehensive README with API docs and quick start guide
@cursor
Copy link

cursor bot commented Feb 20, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @LouisLetcher, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request establishes a foundational cloud-native MEAN stack boilerplate designed for modern web application development. It provides a structured and opinionated starting point, emphasizing best practices in containerization, code quality, and security. The changes introduce a fully functional backend with authentication and user management, paired with an Angular frontend, all configured for seamless local development and deployment readiness.

Highlights

  • Comprehensive MEAN Stack Boilerplate: Introduced a complete, production-ready MEAN (MongoDB, Express.js, Angular, Node.js) stack boilerplate, built with TypeScript and adhering to 12-Factor App principles.
  • Cloud-Native Readiness: Implemented multi-stage Dockerfiles for both backend and frontend, along with a docker-compose.yml for easy local development, including health checks for services.
  • Robust Backend Architecture: Developed a Node.js/Express.js backend with TypeScript, featuring Zod for environment and request validation, JWT authentication, user management (CRUD), Pino logging, and custom error handling.
  • Modern Angular Frontend: Set up an Angular 19 frontend using standalone components, signals, routing with guards, and an authentication service with an HTTP interceptor.
  • Enhanced Code Quality & Security: Integrated ESLint, Prettier, Husky hooks (commitlint, lint-staged), and TypeScript strict mode for consistent code quality. Security measures include Helmet, CORS, rate limiting, bcrypt password hashing, and JWT.
Changelog
  • .editorconfig
    • Added editor configuration for consistent coding styles.
  • .env.example
    • Added an example environment file with configuration for MongoDB, backend, and frontend.
  • .gitignore
    • Added common ignore patterns for development artifacts and sensitive files.
  • .husky/commit-msg
    • Added a Git hook to enforce conventional commit message standards.
  • .husky/pre-commit
    • Added a Git hook to run lint-staged for code formatting and linting before commits.
  • .prettierignore
    • Added configuration to ignore specific files and directories from Prettier formatting.
  • .prettierrc
    • Added Prettier configuration for consistent code formatting.
  • README.md
    • Updated the main README with a detailed overview of the boilerplate, tech stack, project structure, quick start instructions, API endpoints, testing, code quality, security, and environment variables.
  • backend/.dockerignore
    • Added Docker ignore patterns for the backend service.
  • backend/.env.example
    • Added backend-specific example environment variables.
  • backend/Dockerfile
    • Added a multi-stage Dockerfile for building and running the backend in development and production environments.
  • backend/eslint.config.mjs
    • Added ESLint configuration for the backend TypeScript files.
  • backend/jest.config.js
    • Added Jest configuration for backend unit and integration tests.
  • backend/package.json
    • Added backend project dependencies, scripts, and metadata.
  • backend/src/app.ts
    • Added the main Express application setup, including middleware for security, CORS, rate limiting, and route registration.
  • backend/src/config/database.ts
    • Added functions for connecting to and gracefully disconnecting from MongoDB with retry logic.
  • backend/src/config/env.config.ts
    • Added environment variable validation using Zod to ensure correct configuration at startup.
  • backend/src/middleware/error-handler.ts
    • Added a global error handling middleware to catch and process application errors.
  • backend/src/middleware/not-found.ts
    • Added a middleware to handle 404 Not Found routes.
  • backend/src/middleware/validate.ts
    • Added a middleware for request validation using Zod schemas.
  • backend/src/modules/auth/auth.controller.ts
    • Added controllers for user registration, login, and profile retrieval.
  • backend/src/modules/auth/auth.middleware.ts
    • Added JWT authentication middleware to protect routes.
  • backend/src/modules/auth/auth.routes.ts
    • Added API routes for authentication operations.
  • backend/src/modules/auth/auth.service.ts
    • Added service logic for user registration, login, JWT generation, and token verification.
  • backend/src/modules/auth/auth.validation.ts
    • Added Zod schemas for validating authentication request bodies.
  • backend/src/modules/health/health.controller.ts
    • Added controllers for liveness and readiness health checks.
  • backend/src/modules/health/health.routes.ts
    • Added API routes for health checks.
  • backend/src/modules/users/user.model.ts
    • Added the Mongoose schema and model for user data.
  • backend/src/modules/users/users.controller.ts
    • Added controllers for user listing, retrieval, updating, and soft-deletion.
  • backend/src/modules/users/users.routes.ts
    • Added authenticated API routes for user management.
  • backend/src/modules/users/users.service.ts
    • Added service logic for user data access, pagination, and updates.
  • backend/src/modules/users/users.validation.ts
    • Added Zod schemas for validating user ID parameters and update request bodies.
  • backend/src/server.ts
    • Added the main server bootstrap logic, including database connection and graceful shutdown handling.
  • backend/src/utils/app-error.ts
    • Added custom error classes for standardized application error handling.
  • backend/src/utils/logger.ts
    • Added Pino logger configuration for structured logging.
  • backend/src/utils/response.ts
    • Added utility functions for sending standardized API success and error responses.
  • backend/tests/integration/health.test.ts
    • Added integration tests for the health check endpoints.
  • backend/tests/unit/app-error.test.ts
    • Added unit tests for the custom application error classes.
  • backend/tests/unit/response.test.ts
    • Added unit tests for the API response utility functions.
  • backend/tsconfig.build.json
    • Added TypeScript configuration specifically for building the backend project.
  • backend/tsconfig.json
    • Added base TypeScript configuration for the backend project.
  • commitlint.config.js
    • Added Commitlint configuration for enforcing commit message conventions.
  • docker-compose.yml
    • Added a Docker Compose file to orchestrate the MongoDB, backend, and frontend services for local development.
  • eslint.config.mjs
    • Added root ESLint configuration with ignore patterns.
  • frontend/.dockerignore
    • Added Docker ignore patterns for the frontend service.
  • frontend/.editorconfig
    • Added editor configuration for consistent coding styles in the frontend.
  • frontend/.gitignore
    • Added common ignore patterns for the frontend project.
  • frontend/Dockerfile
    • Added a multi-stage Dockerfile for building and serving the Angular frontend with Nginx in production.
  • frontend/README.md
    • Added a README specific to the Angular frontend project.
  • frontend/angular.json
    • Added Angular CLI configuration for the frontend project.
  • frontend/nginx.conf
    • Added Nginx configuration for serving the Angular frontend in a production Docker environment.
  • frontend/package.json
    • Added frontend project dependencies, scripts, and metadata.
  • frontend/proxy.conf.json
    • Added proxy configuration for the Angular development server to forward API requests to the backend.
  • frontend/src/app/app.component.html
    • Added the main application component's HTML template, including navigation and router outlet.
  • frontend/src/app/app.component.scss
    • Added SCSS styles for the main application component.
  • frontend/src/app/app.component.spec.ts
    • Added basic tests for the main application component.
  • frontend/src/app/app.component.ts
    • Added the main application component logic, integrating with the authentication service.
  • frontend/src/app/app.config.ts
    • Added Angular application configuration, including router setup and HTTP interceptors.
  • frontend/src/app/app.routes.ts
    • Added Angular routing configuration with authentication guards.
  • frontend/src/app/core/guards/auth.guard.ts
    • Added Angular route guards to protect authenticated and guest routes.
  • frontend/src/app/core/interceptors/auth.interceptor.ts
    • Added an HTTP interceptor to attach JWT tokens to outgoing requests and handle 401 Unauthorized responses.
  • frontend/src/app/core/services/auth.service.ts
    • Added an Angular authentication service for user login, registration, token management, and user state tracking using signals.
  • frontend/src/app/features/auth/login/login.component.html
    • Added the HTML template for the login component.
  • frontend/src/app/features/auth/login/login.component.scss
    • Added SCSS styles for the login component.
  • frontend/src/app/features/auth/login/login.component.ts
    • Added the login component logic, handling form submission and authentication.
  • frontend/src/app/features/auth/register/register.component.html
    • Added the HTML template for the registration component.
  • frontend/src/app/features/auth/register/register.component.scss
    • Added SCSS styles for the registration component.
  • frontend/src/app/features/auth/register/register.component.ts
    • Added the registration component logic, handling form submission and user creation.
  • frontend/src/app/features/dashboard/dashboard.component.html
    • Added the HTML template for the dashboard component.
  • frontend/src/app/features/dashboard/dashboard.component.scss
    • Added SCSS styles for the dashboard component.
  • frontend/src/app/features/dashboard/dashboard.component.ts
    • Added the dashboard component logic, displaying user information.
  • frontend/src/app/features/home/home.component.html
    • Added the HTML template for the home page component.
  • frontend/src/app/features/home/home.component.scss
    • Added SCSS styles for the home page component.
  • frontend/src/app/features/home/home.component.ts
    • Added the home page component logic.
  • frontend/src/app/shared/models/api-response.model.ts
    • Added TypeScript interfaces for standardized API response structures.
  • frontend/src/app/shared/models/user.model.ts
    • Added TypeScript interfaces for user and authentication-related data models.
  • frontend/src/environments/environment.production.ts
    • Added production environment configuration for the Angular application.
  • frontend/src/environments/environment.ts
    • Added development environment configuration for the Angular application.
  • frontend/src/index.html
    • Added the base HTML file for the Angular application.
  • frontend/src/main.ts
    • Added the main entry point for bootstrapping the Angular application.
  • frontend/src/styles.scss
    • Added global SCSS styles for the frontend application.
  • frontend/src/styles/_auth.scss
    • Added authentication-specific SCSS styles.
  • frontend/tsconfig.app.json
    • Added TypeScript configuration for the Angular application build.
  • frontend/tsconfig.json
    • Added base TypeScript configuration for the Angular frontend project.
  • frontend/tsconfig.spec.json
    • Added TypeScript configuration for Angular unit tests.
  • package.json
    • Added root package.json with workspaces configuration for backend and frontend, and dev tooling scripts.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/ci.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive and well-structured MEAN stack boilerplate. The code quality is very high, adhering to modern best practices for both the Node.js/Express backend and the Angular frontend. The project setup is excellent, featuring robust configurations for Docker, security, validation, logging, and development tooling. I have a few suggestions for improvement regarding Docker layer caching, dependency management, TypeScript typings in Express, and securing default secrets. Overall, this is an excellent foundation for a new project.

NODE_ENV: development
PORT: 3000
MONGO_URI: mongodb://${MONGO_USERNAME:-admin}:${MONGO_PASSWORD:-password}@mongodb:27017/${MONGO_DATABASE:-mean_app}?authSource=admin
JWT_SECRET: ${JWT_SECRET:-dev-secret-change-in-production}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The default JWT_SECRET is a weak and predictable string. Using common default secrets is a security risk, as they can be easily guessed by attackers if this configuration is ever used in a production or staging environment. It's recommended to use a more random, non-obvious default secret even for development.

Comment on lines +4 to +22
FROM node:20-alpine AS base
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci --ignore-scripts
COPY . .

# ============================================
# Stage 2: Development (hot-reload with tsx)
# ============================================
FROM base AS development
ENV NODE_ENV=development
EXPOSE 3000
CMD ["npm", "run", "dev"]

# ============================================
# Stage 3: Build the TypeScript source
# ============================================
FROM base AS build
RUN npm run build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve Docker layer caching and optimize build times, it's recommended to separate the dependency installation from copying the application source code. The current base stage bundles them, causing the cache to be invalidated on any source code change.

By creating a dependencies stage that only handles npm ci, and then having development and build stages copy the source code, you ensure that dependencies are only re-installed when package.json or package-lock.json changes.

# ============================================
# Stage 1: Dependencies
# ============================================
FROM node:20-alpine AS dependencies
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci --ignore-scripts

# ============================================
# Stage 2: Development (hot-reload with tsx)
# ============================================
FROM dependencies AS development
COPY . .
ENV NODE_ENV=development
EXPOSE 3000
CMD ["npm", "run", "dev"]

# ============================================
# Stage 3: Build the TypeScript source
# ============================================
FROM dependencies AS build
COPY . .
RUN npm run build

"jsonwebtoken": "^9.0.2",
"mongoose": "^8.9.5",
"pino": "^9.6.0",
"pino-pretty": "^13.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The pino-pretty package is used for formatting logs only during development and is not needed in production. It should be moved to devDependencies to keep production dependencies clean and reduce the size of the production installation.

}

const payload = verifyToken(token);
(req as Request & { userId: string }).userId = payload.userId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The type casting (req as Request & { userId: string }) is used here and in other controllers to access userId. This can be made cleaner and more type-safe by using TypeScript's declaration merging to extend the Express Request interface.

Consider creating a type definition file (e.g., backend/src/types/express.d.ts) with the following content:

declare namespace Express {
  export interface Request {
    userId?: string;
  }
}

With this in place, you can simply write req.userId = payload.userId; without any casting, and it will be type-checked correctly across your application.

Suggested change
(req as Request & { userId: string }).userId = payload.userId;
req.userId = payload.userId;

@LouisLetcher LouisLetcher deleted the cursor/cloud-native-mean-boilerplate-7f8f branch February 20, 2026 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants